package homework.api02.homework_api02;

public class IntegerDemo {
    public static void main(String[] args) {
        Integer i1 = new Integer(5);
        Integer i2 = new Integer(5);
        System.out.println(i1==i2);
        System.out.println(i1.equals(i2));

        //valueOf会复用一个字节以内-128到127范围内的数据,建议用valueOf
        Integer i3 = Integer.valueOf(5);
        Integer i4 = Integer.valueOf(5);
        System.out.println(i3==i4);//true
        System.out.println(i3.equals(i4));//true

        //包装类与基本类之间的转换
        Integer i = Integer.valueOf(5);
        int j = i.intValue();

        //通过包装类获取基本类型的最大值和最小值
        int max = Integer.MAX_VALUE;
        int min = Integer.MIN_VALUE;
        System.out.println("int的最大值为"+max+"int最小值为"+min);

        double max1 = Double.MAX_EXPONENT;
        double min1 = Double.MIN_EXPONENT;
        System.out.println("double最大值为"+max1+"double最小值为"+min1);

        //包装类可以将字符串转换为对应基本类型
        String s1 = "123";
        int age = Integer.parseInt(s1);
        System.out.println(age);

        String s2 = "3.1516";
        double price = Double.parseDouble(s2);
        System.out.println(price);

        //自动装箱 自动拆箱
        Integer a = 5;//Integer a = Integer.valueOf(5);装箱
        int b = a;//int b = a.intvalue(); 拆箱
    }
}
